package model

import (
	"database/sql"
	"strings"
)

type MerchantDB struct {
}

func (that MerchantDB) Get(dest interface{}, query string, args ...interface{}) error {
	if strings.Contains(query, "for update") {
		return meta.MasterDB.Get(dest, query, args...)
	} else {
		return meta.SlaveDB.Get(dest, query, args...)
	}
}

func (that MerchantDB) Select(dest interface{}, query string, args ...interface{}) error {
	return meta.SlaveDB.Select(dest, query, args...)
}

func (that MerchantDB) Exec(query string, args ...any) (sql.Result, error) {
	return meta.MasterDB.Exec(query, args...)
}

func (that MerchantDB) Begin() (*sql.Tx, error) {
	return meta.MasterDB.Begin()
}
